//==================================================================
//  Copyright (C) 2006  Davide Pasca
//
//  This library is free software; you can redistribute it and/or
//  modify it under the terms of the GNU Lesser General Public
//  License as published by the Free Software Foundation; either
//  version 2.1 of the License, or (at your option) any later version.
//
//  This library is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
//  Lesser General Public License for more details.
//
//  You should have received a copy of the GNU Lesser General Public
//  License along with this library; if not, write to the Free Software
//  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
//==================================================================
///
///
///
///
///
//==================================================================

#include "stdafx.h"
#include "m5d_mesh_geometry.h"
#include "m5d_scene.h"

//==================================================================
namespace M5D {

//==================================================================
DispList * MeshGeometry::OpenDispListIndex( Scene *scenep, PackVert::Type packvert_type, u_int max_verts, u_int max_prim_indices )
{
	if ( packvert_type == PackVert::TYPE_ANY )
	{
		//PASSERT( _displist_idxp != NULL );
	}
	else
	{
		SAFE_DELETE( _displist_idxp );
		_displist_idxp = scenep->NewDispList( packvert_type, max_verts, max_prim_indices );
	}

	if ( _displist_idxp )
		_displist_idxp->LockRW( __FILE__, __LINE__ );

	return _displist_idxp;
}

//==================================================================
DispList * MeshGeometry::OpenDispListVertex( Scene *scenep, PackVert::Type packvert_type, u_int max_verts )
{
	if ( packvert_type == PackVert::TYPE_ANY )
	{
		//PASSERT( _displist_vtxp != NULL );
	}
	else
	{
		SAFE_DELETE( _displist_vtxp );
		_displist_vtxp = scenep->NewDispList( packvert_type, max_verts, 0 );

	}

	if ( _displist_vtxp )
		_displist_vtxp->LockRW( __FILE__, __LINE__ );

	return _displist_vtxp;
}

//==================================================================
void MeshGeometry::CloseDispListIndex()
{
	if ( _displist_idxp )
		_displist_idxp->Unlock();
}

//==================================================================
void MeshGeometry::CloseDispListVertex()
{
	if ( _displist_vtxp )
		_displist_vtxp->Unlock();
}

};